import React, {
    Component,
    PropTypes
} from 'react';
import {
    Router,
    Route,
    IndexRoute,
    browserHistory,
    hashHistory
} from 'react-router';

/**
 * (路由根目录组件，显示当前符合条件的组件)
 *
 * @class Roots
 * @extends {Component}
 */
class Roots extends Component {
    render() {
        return (
            <div>{this.props.children}</div>
        );
    }
}
//商户中心登录页
const BuinessLogin = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/businessCenter/Login').default)
    }, 'BuinessLogin')
}
//商户中心首页
const BuinessIndex = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/businessCenter/Index').default)
    }, 'BuinessIndex')
}
//创建商户
const BusinessForm = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/businessCenter/BusinessForm').default)
    }, 'BusinessForm')
}
//商品管理
const GoodsManage = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/businessCenter/GoodsManage').default)
    }, 'GoodsManage')
}
//订单管理
const OrderManage = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/businessCenter/OrderManage').default)
    }, 'OrderManage')
}
//企业资料
const CompanyData = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/businessCenter/CompanyData').default)
    }, 'CompanyData')
}
//消费验证
const ConsumeVerify = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/businessCenter/ConsumeVerify').default)
    }, 'ConsumeVerify')
}
//商品详情
const GoodsDetail = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/businessCenter/GoodsDetail').default)
    }, 'GoodsDetail')
}
//添加商品
const AddGoods = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/businessCenter/AddGoods').default)
    }, 'AddGoods')
}
//订单详情
const OrderDetail = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/businessCenter/OrderDetail').default)
    }, 'OrderDetail')
}
//序列号验证
const NumberVerify = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/businessCenter/NumberVerify').default)
    }, 'NumberVerify')
}

//商品使用情况
const UseInfo = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/businessCenter/UseInfo').default)
    }, 'UseInfo')
}
//测试路由
const BsTest = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/businessCenter/mock/Testt').default)
    }, 'BsTest')
}
//测试路由
const BusinessForgetPwd = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/businessCenter/ForgetPwd').default)
    }, 'BusinessForgetPwd')
}

//测试路由
const BusinessReg = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/businessCenter/register').default)
    }, 'BusinessReg')
}


// const Test = (location, cb) => {
//     require.ensure([], require => {
//         cb(null, require('./Component/Test').default)
//     }, 'Test')
// }

const RouteConfig = (
    <Router path="/" history={hashHistory}>
        <IndexRoute getComponent={BuinessLogin}/>
        <Route path="businesslogin" getComponent={BuinessLogin}/>//商户登录
        <Route path="businessReg" getComponent={BusinessReg}/>//商户登录
        <Route path="businessForgetPwd" getComponent={BusinessForgetPwd}/>//商户修改密码
        <Route path="businessIndex(/:company)" getComponent={BuinessIndex}/> //商户中心首页
        <Route path="businessForm(/:needAudit)" getComponent={BusinessForm}/> //商户中心首页
        <Route path="goodsManage" getComponent={GoodsManage}/>//商品管理
        <Route path="orderManage" getComponent={OrderManage}/> //订单管理
        <Route path="companyData" getComponent={CompanyData}/> //企业资料
        <Route path="consumeVerify" getComponent={ConsumeVerify}/> //消费验证
        <Route path="bstest" getComponent={BsTest}/> //测试路由
        <Route path="goodsDetail/:goodId" getComponent={GoodsDetail}/>//商品详情
        <Route path="addGoods(/:goodId)" getComponent={AddGoods}/>//添加商品
        <Route path="orderDetail/:id" getComponent={OrderDetail}/>//订单详情
        <Route path="numberVerify" getComponent={NumberVerify}/>//序列号验证
        <Route path="useInfo(/:companyId)(/:get)(/:unUsed)(/:used)" getComponent={UseInfo}/>//商品使用情况
        {/*<Route path='test' getComponent={Test}/>*/}
        <Route path="*" getComponent={BuinessLogin}/>
    </Router>
);

export default RouteConfig;
